﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tab2sql
{

    public class Series
    {
        public string[] mySeries = new string[3000];
        public int Count = -1;
        public int DistinctCount = -1;
        public int Largest = -1;
        public int Smallest = -1;
        public int Mean = -1;
        public int Median = -1;
        public int Mode = -1;
        public StringBuilder finalMessage = new StringBuilder();
        public Series(string input)
        {

            mySeries = input.Split('\n');

            Count = getCount();
            DistinctCount = getDistinctCount();
            finalMessage.AppendLine("This series contains " + Count.ToString() + " elements");
            finalMessage.AppendLine("This series contains " + DistinctCount.ToString() + " unique elements");
            finalMessage.AppendLine("Longest value is " + getLongestLine() + " ");
            finalMessage.AppendLine("Shortest value is " + getShortestLine() + " ");
            //Largest = getLargest();
            //Smallest = getSmallest();
        }

        private int getSmallest()
        {
            throw new NotImplementedException();
        }

        private int getLargest()
        {
            throw new NotImplementedException();
        }

        private int getCount()
        {
            int ReturnValue = 0;
            int i = 0;
            foreach (string myValue in mySeries)
            {
                if (myValue != null && myValue.Length > 0)
                {
                    i++;
                }
            }

            ReturnValue = i;
            return ReturnValue;
        }

        private int getDistinctCount()
        {
            string[] tmp = new string[mySeries.Count()];
            int ReturnValue = 0;
            int i = 0;
            foreach (string myValue in mySeries)
            {
                if (myValue != null && myValue.Length > 0)
                {
                    if (tmp.Contains(myValue))
                    {
                        //whatever
                    }
                    else { i++;
                    tmp[i] = myValue;
                    
                    }
                }
            }

            ReturnValue = i;
            return ReturnValue;
        }

        private string getLongestLine()
        {
            string[] tmp = new string[mySeries.Count()];
            string ReturnValue = "";
            int i = 0;
            int CurrentRecord = 0;
            int length = 0;
            foreach (string myValue in mySeries)
            {
                if (myValue != null && myValue.Length > 0)
                {
                    
                    length = myValue.Trim().Length;
                    if (length > CurrentRecord)
                    {
                        CurrentRecord = length;
                        ReturnValue = myValue;
                    }
                }
            }

            
            return ReturnValue;
        }
        private string getShortestLine()
        {
            string[] tmp = new string[mySeries.Count()];
            string ReturnValue = "";
            int i = 0;
            int CurrentRecord = 0;
            int length = 0;
            foreach (string myValue in mySeries)
            {
                if (myValue != null && myValue.Length > 0)
                {

                    length = myValue.Trim().Length;
                    if (length <CurrentRecord || CurrentRecord==0)
                    {
                        CurrentRecord = length;
                        ReturnValue = myValue;
                    }
                }
            }


            return ReturnValue;
        }


    }

}
